﻿<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('数据库数据管理')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
	<meta charset="utf-8" />
</head>
<body class="gray-bg">
	<div class="ui-layout-center">
		<div class="container-div">
			<div class="row">
				<div class="col-sm-12 search-collapse">
					<form id="user-form">
						<div class="select-list">
							<ul>
								<li>
									字段名称：<input type="text" name="protoKey"/>
								</li>
								<li>
									字段值：<input type="text" name="valOfKey"/>
								</li>
								
								<li>
									<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								    <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
								</li>
							</ul>
						</div>
					</form>
				</div>
				
		        
		        <div class="col-sm-12 select-table table-striped">
				    <table id="bootstrap-table"></table>
				</div>
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: layout-latest-js" />
	<th:block th:include="include :: ztree-js" />
	<script th:inline="javascript">

		$(function() {
		    var panehHidden = false;
		    if ($(this).width() < 769) {
		        panehHidden = true;
		    }
		    $('body').layout({ initClosed: panehHidden, west__size: 185 });
	     	// 回到顶部绑定
	    	if ($.fn.toTop !== undefined) {
	    		var opt = {
	    			win:$('.ui-layout-center'),
	    			doc:$('.ui-layout-center')
	    		};
	    		$('#scroll-up').toTop(opt);
	    	}
	     	/**
	    	$.ajax({
	    		url: 'http://192.168.2.2:8081/protoData/query',
	    		type: 'POST',
				contentType:"application/json;charset=utf-8",
	    		data: JSON.stringify({protoKey: "山底气压15", valOfKey: "169"}),
	    		success: function(response) {
	    		console.log(response);
	    		},
	    		error: function(error) {
	    		console.log(error);
	    		}
	    		});
	     	**/
		    queryUserList();
		    //queryDeptTree();
		});

		function queryUserList() {
		    var options = {
		        url: "/data/databaseList",
		        //data: data,
		        modalName: "数据库数据",
		        contentType: "JSON",
		        columns: [{
		            checkbox: true
		        },
		        {
		            field: 'id',
		            title: '数据ID'
		        },
		        {
		            field: 'protoName',
		            title: '协议名称'
		        },
		        {
		            field: 'autoBak',
		            title: '自动备份路径'
		        },
		        {
		            field: 'protoDataNum',
		            title: '协议内容个数'
		        },
		        {
		            field: 'protoDataSize',
		            title: '协议体内容长度'
		        },
		        {
		            field: 'reqTime',
		            title: '请求时间',
		            sortable: true
		        },
		        {
		            field: 'inserttime',
		            title: '入库时间',
		            sortable: true
		        },
		        {
		            field: 'expireDate',
		            title: '过期时间',
		            sortable: true
		        }]
		    };
		    $.table.init(options);
		}
		
		/**
		function queryDeptTree()
		{
			var url = ctx + "system/user/deptTreeData";
			var options = {
		        url: url,
		        expandLevel: 2,
		        onClick : zOnClick
		    };
			$.tree.init(options);
			
			function zOnClick(event, treeId, treeNode) {
				$("#deptId").val(treeNode.id);
				$("#parentId").val(treeNode.pId);
				$.table.search();
			}
		}
		
		$('#btnExpand').click(function() {
			$._tree.expandAll(true);
		    $(this).hide();
		    $('#btnCollapse').show();
		});
		
		$('#btnCollapse').click(function() {
			$._tree.expandAll(false);
		    $(this).hide();
		    $('#btnExpand').show();
		});
		
		$('#btnRefresh').click(function() {
			queryDeptTree();
		});
		**/
		
		
		/* 自定义重置-表单重置/隐藏框/树节点选择色/搜索 */
		function resetPre() {
			resetDate();
			$("#user-form")[0].reset();
			$(".curSelectedNode").removeClass("curSelectedNode");
			$.table.search();
		}

		/* 用户管理-部门 */
		function dept() {
			var url = ctx + "system/dept";
			$.modal.openTab("部门管理", url);
		}

		/* 用户管理-重置密码 */
		function resetPwd(userId) {
		    var url = prefix + '/resetPwd/' + userId;
		    $.modal.open("重置密码", url, '800', '300');
		}
		
		/* 用户管理-分配角色 */
		function authRole(userId) {
		    var url = prefix + '/authRole/' + userId;
		    $.modal.openTab("用户分配角色", url);
		}
		
		/* 用户状态显示 */
		function statusTools(row) {
		    if (row.status == 1) {
    			return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> ';
    		} else {
    			return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.userId + '\')"></i> ';
    		}
		}
		
		/* 用户管理-停用 */
		function disable(userId) {
			$.modal.confirm("确认要停用用户吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 1 });
		    })
		}

		/* 用户管理启用 */
		function enable(userId) {
			$.modal.confirm("确认要启用用户吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 0 });
		    })
		}
	</script>
</body>
</html>